package com.mobilepoc.jersey.storage;

import java.util.ArrayList;
import java.util.List;

import com.mobilepoc.jersey.model.Account;
import com.mobilepoc.jersey.model.AccountInformation;
import com.mobilepoc.jersey.model.AccountType;


public class AccountStorage
{
   private static List<Account> accounts = new ArrayList<Account>();
   private static List<AccountInformation> accountInformations=new ArrayList<AccountInformation>();

   static {
      Account account1 = new Account("123465", "Mitt Lönekonto");
      Account account2 = new Account("234567","Stora Sparkontot");
      Account account3 = new Account("999999","Pensionskontot");
      Account account4 = new Account("654321","Företagskonto");
      accounts.add(account1);
      accounts.add(account2);
      accounts.add(account3);
      accounts.add(account4);
      
      accountInformations.add(new AccountInformation(account1.getArrangementId(),account1.getCustomerArrangementName(),0,2500,2500,0,AccountType.DEPOSIT_ACCOUNT));
      accountInformations.add(new AccountInformation(account2.getArrangementId(),account2.getCustomerArrangementName(),1.0,50000,50000,0,AccountType.SAVINGS_ACCOUNT));
      accountInformations.add(new AccountInformation(account3.getArrangementId(),account3.getCustomerArrangementName(),2.4,250000,250000,0,AccountType.TERM_DEPOSIT_ACCOUNT));
      accountInformations.add(new AccountInformation(account4.getArrangementId(),account4.getCustomerArrangementName(),0,25000,5000,20000,AccountType.DEPOSIT_ACCOUNT));
   }

   public static List<Account> getAccounts() {
	   return accounts;
   }
   
   
   public static Account getAccount(String accountNumber){
	   for(Account account : accounts){
		   if(account.getArrangementId().equals(accountNumber)){
			   return account;
		   }
	   }
	   return null;
   }
   
   public static List<Account> getMatchingAccounts(String accountNumber, String customerArrangementName){
	   List<Account> matchingAccounts = new ArrayList<Account>();
	   for(Account account : accounts){
		   if(account.getArrangementId().equals(accountNumber) && account.getCustomerArrangementName().equals(customerArrangementName)){
			   matchingAccounts.add(account);
		   }
	   }
	   return matchingAccounts;
   }
      public static AccountInformation getAccountInformation(String accountNumber) {
      for (AccountInformation accountInfo : accountInformations) {
         if (accountInfo.getArrangementId().equals(accountNumber)) {
            return accountInfo;
         }
      }
      return null;






 }
}
